﻿
	//
	// Namespace block as created by the parser
	//
public partial class NamespaceDefinition {


    public override void GetCompletionStartingWith(string prefix, List<string> results) {
        if (Usings == null)
            return;

        foreach (var un in Usings) {
            if (un.Alias != null)
                continue;

            var name = un.NamespaceExpression.Name;
            if (name.StartsWith(prefix))
                results.Add(name);
        }


        IEnumerable<string> all = Enumerable.Empty<string>();

        foreach (Namespace using_ns in namespace_using_table) {
            if (prefix.StartsWith(using_ns.Name)) {
                int ld = prefix.LastIndexOf('.');
                if (ld != -1) {
                    string rest = prefix.Substring(ld + 1);

                    all = all.Concat(using_ns.CompletionGetTypesStartingWith(rest));
                }
            }
            all = all.Concat(using_ns.CompletionGetTypesStartingWith(prefix));
        }

        results.AddRange(all);

        base.GetCompletionStartingWith(prefix, results);
    }


    public void EnableRedefinition() {
        _usingNamespaces = null;
    }

}



public sealed partial class ClassDefinition : TypeDefinition {

    public override void GetCompletionStartingWith(string prefix, List<string> results) {
        base.GetCompletionStartingWith(prefix, results);

        var bt = base_type;
        while (bt != null) {
            results.AddRange(MemberCache.GetCompletitionMembers(this, bt, prefix).Where(l => l.IsStatic).Select(l => l.Name));
            bt = bt.baseClass;
        }
    }

}
